#include "StdAfx.h"
#include "PointGeometry.h"
#include "Drawer.h"

CPointGeometry::CPointGeometry()
{
	m_x = m_y = 0;
}

CPointGeometry::CPointGeometry(double x, double y):m_x(x),m_y(y)
{
}

CPointGeometry::~CPointGeometry()
{
}

void CPointGeometry::draw(CDrawer *pDrawer)
{
	pDrawer->drawPoint(m_x,m_y);
}

CLineGeometry::CLineGeometry()
{

}

CLineGeometry::~CLineGeometry()
{
	for (int ii = 0; ii < m_points.GetCount();ii++)
	{
		delete m_points.GetAt(ii);
	}
	m_points.RemoveAll();
}

void CLineGeometry::addPoint(CPointGeometry* pPoint)
{
	m_points.Add(pPoint);
}

void CLineGeometry::draw(CDrawer *pDrawer)
{
	for (int ii = 0; ii < m_points.GetCount() - 1;ii++)
	{
		pDrawer->drawLine(m_points.GetAt(ii),m_points.GetAt(ii+1));
	}
}

CLineRingGeometry::CLineRingGeometry()
{

}

CLineRingGeometry::~CLineRingGeometry()
{
	for (int ii = 0; ii < m_points.GetCount();ii++)
	{
		delete m_points.GetAt(ii);
	}
	m_points.RemoveAll();
}

void CLineRingGeometry::addPoint(CPointGeometry* pPoint)
{
	m_points.Add(pPoint);
}

void CLineRingGeometry::draw(CDrawer *pDrawer)
{
	for (int ii = 0; ii < m_points.GetCount() - 1;ii++)
	{
		pDrawer->drawLine(m_points.GetAt(ii),m_points.GetAt(ii+1));
	}
	pDrawer->drawLine(m_points.GetAt(m_points.GetCount() - 1),m_points.GetAt(0));
}

CMultiLineGeometry::CMultiLineGeometry()
{
}

CMultiLineGeometry::~CMultiLineGeometry()
{
	for (int ii = 0; ii < m_lines.GetCount();ii++)
	{
		delete m_lines.GetAt(ii);
	}
	m_lines.RemoveAll();
}

void CMultiLineGeometry::addLine(CLineGeometry* pLineRing)
{
	m_lines.Add(pLineRing);
}

void CMultiLineGeometry::draw(CDrawer *pDrawer)
{
	for (int ii = 0; ii < m_lines.GetCount();ii++)
	{
		m_lines.GetAt(ii)->draw(pDrawer);
	}
}


CPolygonGeometry::CPolygonGeometry()
{
}

CPolygonGeometry::~CPolygonGeometry()
{
	for (int ii = 0; ii < m_lineRings.GetCount();ii++)
	{
		delete m_lineRings.GetAt(ii);
	}
	m_lineRings.RemoveAll();
}

void CPolygonGeometry::addLineRing(CLineRingGeometry* pLineRing)
{
	m_lineRings.Add(pLineRing);
}

void CPolygonGeometry::draw(CDrawer *pDrawer)
{
	for (int ii = 0; ii < m_lineRings.GetCount();ii++)
	{
		m_lineRings.GetAt(ii)->draw(pDrawer);
	}
}

CMultiPolygonGeometry::CMultiPolygonGeometry()
{
}

CMultiPolygonGeometry::~CMultiPolygonGeometry()
{
	for (int ii = 0; ii < m_polygons.GetCount();ii++)
	{
		delete m_polygons.GetAt(ii);
	}
	m_polygons.RemoveAll();
}

void CMultiPolygonGeometry::addPolygon(CPolygonGeometry*pPolygon)
{
	m_polygons.Add(pPolygon);
}

void CMultiPolygonGeometry::draw(CDrawer *pDrawer)
{
	for (int ii = 0; ii < m_polygons.GetCount();ii++)
	{
		m_polygons.GetAt(ii)->draw(pDrawer);
	}
}

